<?php

include_once APPLICATION_DIR . "/application/model/PARAMETER.php";
class Parameter extends DataObjects_PARAMETER
{
	function saveValue($id_param,$value, $label=NULL)
	{
		if ($this->canViewForm())
		{
			$this->get($id_param);
			if ($this->VALUE != $value)
			{
				$this->VALUE = $value;
				$this->LABEL = $label;
				return $this->update();
			}
		}
		return false;
	}

	/*
	* Load and define constants from table PARAMETER
	*/
	public static function loadConstants()
	{
		$param = new Parameter();
		$param->find();
		while ($param->fetch())
		{
			if (defined($param->NOM))
				unset($param->NOM);

			define($param->NOM,$param->VALUE);
		}
	}

	/** check whether the current login user can view the emplacement form
	* @return bool
	*/
	function canViewForm()
	{
		if ($_SESSION["userClasse"] == "user_regie")
		{
			return false;
		}
		return true;
	}
}